/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import interfaces.InternationalizableEntity;
import interfaces.InternationalizableEntityDescription;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "sector_description")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SectorDescription.findAll", query = "SELECT s FROM SectorDescription s"),
    @NamedQuery(name = "SectorDescription.findByIdSectorDescription", query = "SELECT s FROM SectorDescription s WHERE s.idSectorDescription = :idSectorDescription"),
    @NamedQuery(name = "SectorDescription.findByDescription", query = "SELECT s FROM SectorDescription s WHERE s.description = :description")})
public class SectorDescription implements Serializable, InternationalizableEntityDescription {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_SECTOR_DESCRIPTION")
    private Integer idSectorDescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "DESCRIPTION")
    private String description;
    @JoinColumn(name = "SECTOR", referencedColumnName = "ID_SECTOR")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Sector sector;
    @JoinColumn(name = "LANGUAGE", referencedColumnName = "ID_LANGUAGE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Language language;

    public SectorDescription() {
    }

    public SectorDescription(Integer idSectorDescription) {
        this.idSectorDescription = idSectorDescription;
    }

    public SectorDescription(Integer idSectorDescription, String description) {
        this.idSectorDescription = idSectorDescription;
        this.description = description;
    }

    public Integer getIdSectorDescription() {
        return idSectorDescription;
    }

    public void setIdSectorDescription(Integer idSectorDescription) {
        this.idSectorDescription = idSectorDescription;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Sector getSector() {
        return sector;
    }

    public void setSector(Sector sector) {
        this.sector = sector;
    }

    public Language getLanguage() {
        return language;
    }

    public void setLanguage(Language language) {
        this.language = language;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSectorDescription != null ? idSectorDescription.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SectorDescription)) {
            return false;
        }
        SectorDescription other = (SectorDescription) object;
        if ((this.idSectorDescription == null && other.idSectorDescription != null) || (this.idSectorDescription != null && !this.idSectorDescription.equals(other.idSectorDescription))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.SectorDescription[ idSectorDescription=" + idSectorDescription + " ]";
    }

    @Override
    public InternationalizableEntity getEntity() {
        return getSector();
    }
    
}
